<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: huajie <banhuajie@163.com>
// +----------------------------------------------------------------------

namespace Admin\Model;
use Think\Model;

/**
 * 推广模块
 * @author huajie <banhuajie@163.com>
 */

class TuigModel extends Model {
	
	/**
	 * 查询推广费用
	 * $begin 开始时间
	 * $end   结束时间
	 * $value 渠道ID
	 */
	public function map($begin,$end,$value){
		$begin = strtotime($begin);
        $end   = strtotime($end);
        $map['time']   = array('between',array($begin,$end+86399));
		switch($value){

			case "32":
				$data = $this->where($map)->sum('baidu');
				break;
				
			case "84":
				$data = $this->where($map)->sum('so');
				break;
				
			case "141":
				$data = $this->where($map)->sum('google');
				break;
				
			case "142":
				$data = $this->where($map)->sum('sogou');
				break;
				
			case "117":
				$data = $this->where($map)->sum('dazhong');
				break;
				
			case "107":
				$data = $this->where($map)->sum('weixin');
				break;
				
			case "112":
				$data = $this->where($map)->sum('weibo');
				break;	
				
			case "154":
				$data = $this->where($map)->sum('tianmao');
				break;
				
			case "164":
				$data = $this->where($map)->sum('smtg');
				break;
			
			case "143":
				$data = $this->where($map)->sum('laoguketj');
				break;
			
			case "144":
				$data = $this->where($map)->sum('yuangongtj');
				break;				
			
			case "999":
				$data = $this->where($map)->sum('baidu+so+google+sogou+dazhong+weixin+weibo+tianmao+smtg+laoguketj+yuangongtj');		
				break;		
			
	/* 		default:
				
				$data = $this->where($map)->sum('baidu+so+google+sogou+dazhong+weixin+weibo+tianmao');		
				break; */	
		}
		
		return  $data;
	}
}
